#!usr/bin/node

const Router = require('koa-router'),
      router = new Router();

const authors = require('../models/authors.js');

router.prefix('/api/authors');

router.get('/',async (ctx,next) => {
  const {page,limit} = ctx.query;

  ctx.body = await authors.getAuthorsByPage(page,limit);
});

router.get('/:authorName',async (ctx,next) => {
  const {authorName} = ctx.params;

  ctx.body = res;
});

router.post('/',async (ctx,next) => {
  const {authorName} = ctx.request.body;
  console.log(`添加新的漫画书作者信息:${authorName}`);

  const res = new ResData();

  ctx.body = res;
});

router.put('/:id',async (ctx,next) => {
  const {id} = ctx.params,
        {authorName} = ctx.request.body;
  console.log(`修改某id = ${id}的漫画书作者信息:${authorName}`);

  const res = new ResData();

  ctx.body = res;
});

router.delete('/:id',async (ctx,next) => {
  const {id} = ctx.params;
  console.log(`删除某id = ${id}的漫画书作者信息`);

  const res = new ResData();

  ctx.body = res;
});

module.exports = router;
